package cn.llming.sys.service.impl;

import cn.llming.sys.domain.Dictionary;
import cn.llming.sys.mapper.DictionaryMapper;
import cn.llming.sys.mapper.DictionaryitemMapper;
import cn.llming.sys.service.IDictionaryService;
import cn.llming.basic.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.lang.annotation.Target;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author luolingmin
 * @since 2023-03-13
 */
@Service
public class DictionaryServiceImpl extends BaseServiceImpl<Dictionary> implements IDictionaryService {

    @Autowired
    private DictionaryitemMapper dictionaryitemMapper;

    @Autowired
    private DictionaryMapper dictionaryMapper;

    @Override
    @Transactional
    public void delete(Serializable id) {

        List<Long> longs = new ArrayList<>();
        longs.add((Long)id);


        dictionaryitemMapper.patchRemoveByDictionaryitem(longs);
        dictionaryMapper.delete(id);
    }

    @Override
    @Transactional
    public void batchDelete(List<Long> ids) {

        dictionaryitemMapper.patchRemoveByDictionaryitem(ids);
        dictionaryMapper.batchRemove(ids);
    }
}
